
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 1
 * @Author : WangRuoyu 
 * @Date : 2023/5/14 15:47
 */

#include "iostream"
#include "cstring"
#include "algorithm"

using namespace std;

int main() {
    int n;
    cin >> n;
    int nums[n];
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }

    sort(nums, nums + n);

    int res = nums[(n - 1) / 2];
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (nums[i] > res) cnt++;
        else if (nums[i] < res)cnt--;
    }
    if (cnt == 0) cout << res;
    else cout << -1;

    return 0;
}